package com.one.common.view.pop;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.PopupWindow;

/**
 * Author：zhulunjun
 * Time：2017/9/13
 * description：pop基类
 */

public class BasePopupWindow extends PopupWindow {
    public Context mContext;
    public View mView;

    public BasePopupWindow(Context context,int layoutRes) {
        super(context);
        this.mContext = context;
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mView = inflater.inflate(layoutRes, null);
        // 设置窗口属性
        this.setWidth(WindowManager.LayoutParams.MATCH_PARENT);
        this.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
        this.setBackgroundDrawable(new BitmapDrawable());
        // 设置SelectPicPopupWindow的View
        this.setContentView(mView);
        // 设置SelectPicPopupWindow弹出窗体可点击
        this.setFocusable(true);
        this.setOutsideTouchable(true);
        // 刷新状态
        this.update();
//        this.setClippingEnabled(false);
//        setAnimationStyle(R.style.bottom_dialog_top);
    }

    public void initView(){

    }

    /**
     * 设置界面透明度
     */
    public void setActivityAlpha(float alpha) {
        Activity activity = (Activity) mContext;
        WindowManager.LayoutParams params = activity.getWindow().getAttributes();
        params.alpha = alpha;
        activity.getWindow().setAttributes(params);
    }

}
